package com.icbc.digitalwallet.common.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @PackgeName: com.icbc.digitalwallet.common.util
 * @ClassName: TaskUtils
 * @Author: tx
 * Date: 2021/7/22 10:38
 * project name: digitalwallet
 * @Version:
 * @Description:
 */
@Component
public class TaskUtils {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    @Scheduled(cron = "59 59 23 * * ?")
    public void delKeys(){
        //获取所有以times-开头的键 并删除
        Set<String> keys = redisTemplate.keys("times-*");
        redisTemplate.delete(keys);
    }
}
